package com.my.security.dao;

import com.my.security.model.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PermissionMapper {
    @Select("select * from SYS_PERMISSION")
    List<Permission> getList();

    @Select("select sp.* from sys_user su\n" +
            "left join sys_user_role sur\n" +
            "on su.id=sur.userid\n" +
            "left join sys_role_permission srp\n" +
            "on srp.roleid=sur.roleid\n" +
            "left join sys_permission sp\n" +
            "on sp.id=srp.permissionid\n" +
            "where su.username=#{username}")
    List<Permission> getUserPermission(String username);
}
